package com.tjtt.gwm.dao.impl;

import java.util.Map;

import com.tjtt.gwm.dao.ShebeiweibaoqueryDao;
import com.tjtt.tdm.base.BaseHibernateDao;
import com.tjtt.tdm.base.PageResult;

public class ShebeiweibaoqueryDaoImpl extends BaseHibernateDao implements ShebeiweibaoqueryDao {

	@Override
	public PageResult queryDataList(Map filterMap) {
		StringBuffer countString = new StringBuffer();
		countString.append("select count(*) from GWM_SHEBEIWEIBAO s where 1 = 1 ");
		StringBuffer queryString = new StringBuffer();	
		queryString.append("select s.ID,s.SHEBEIID,s.SHEBEINAME, s.WEIBAOXIANGMU, s.WEIBAOJIZHUN, s.CELIANGBIANLIANG,s.CAOZUOYAODIAN,s.SHEBEINO, s.GUIGEXINGHAO,s.BUMENID,"+ 
				"s.BUMENNAME,s.XUHAO, s.BAOYANGJIBIE, s.GONGJU,s.LAOBAO,s.BAOYANGZHOUQI, s.SHANGCIWEIBAOTIME, s.TIXINGTIANSHU,s.WEIBAOTIME from GWM_SHEBEIWEIBAO s where 1=1");
		if(null!=filterMap && !filterMap.isEmpty()){
			if(null!=filterMap.get("BUMENNAME") && !"".equals(filterMap.get("BUMENNAME"))){
				queryString.append(" and s.BUMENNAME like '%"+filterMap.get("BUMENNAME")+"%'");
				countString.append(" and s.BUMENNAME like '%"+filterMap.get("BUMENNAME")+"%'");
			}
			if(null!=filterMap.get("SHEBEINAME") && !"".equals(filterMap.get("SHEBEINAME"))){
				queryString.append(" and s.SHEBEINAME like '%"+filterMap.get("SHEBEINAME")+"%'");
				countString.append(" and s.SHEBEINAME like '%"+filterMap.get("SHEBEINAME")+"%'");
			}
			if(null!=filterMap.get("SHEBEINO") && !"".equals(filterMap.get("SHEBEINO"))){
				queryString.append(" and s.SHEBEINO like '%"+filterMap.get("SHEBEINO")+"%'");
				countString.append(" and s.SHEBEINO like '%"+filterMap.get("SHEBEINO")+"%'");
			}
			if(null!=filterMap.get("GUIGEXINGHAO") && !"".equals(filterMap.get("GUIGEXINGHAO"))){
				queryString.append(" and s.GUIGEXINGHAO like '%"+filterMap.get("GUIGEXINGHAO")+"%'");
				countString.append(" and s.GUIGEXINGHAO like '%"+filterMap.get("GUIGEXINGHAO")+"%'");
			}
			if(null!=filterMap.get("WEIBAOXIANGMU") && !"".equals(filterMap.get("WEIBAOXIANGMU"))){
				queryString.append(" and s.WEIBAOXIANGMU like '%"+filterMap.get("WEIBAOXIANGMU")+"%'");
				countString.append(" and s.WEIBAOXIANGMU like '%"+filterMap.get("WEIBAOXIANGMU")+"%'");
			}
			if(null!=filterMap.get("WEIBAOJIZHUN") && !"".equals(filterMap.get("WEIBAOJIZHUN"))){
				queryString.append(" and s.WEIBAOJIZHUN like '%"+filterMap.get("WEIBAOJIZHUN")+"%'");
				countString.append(" and s.WEIBAOJIZHUN like '%"+filterMap.get("WEIBAOJIZHUN")+"%'");
			}
			if(null!=filterMap.get("CELIANGBIANLIANG") && !"".equals(filterMap.get("CELIANGBIANLIANG"))){
				queryString.append(" and s.CELIANGBIANLIANG like '%"+filterMap.get("CELIANGBIANLIANG")+"%'");
				countString.append(" and s.CELIANGBIANLIANG like '%"+filterMap.get("CELIANGBIANLIANG")+"%'");
			}
			if(null!=filterMap.get("BAOYANGJIBIE") && !"".equals(filterMap.get("BAOYANGJIBIE"))){
				queryString.append(" and s.BAOYANGJIBIE like '%"+filterMap.get("BAOYANGJIBIE")+"%'");
				countString.append(" and s.BAOYANGJIBIE like '%"+filterMap.get("BAOYANGJIBIE")+"%'");
			}
			if(null!=filterMap.get("STARTWEIBAOTIME") && !"".equals(filterMap.get("STARTWEIBAOTIME"))){
				queryString.append(" and s.WEIBAOTIME >= '"+filterMap.get("STARTWEIBAOTIME")+"'");
				countString.append(" and s.WEIBAOTIME >= '"+filterMap.get("STARTWEIBAOTIME")+"'");
			}
			if(null!=filterMap.get("ENDWEIBAOTIME") && !"".equals(filterMap.get("ENDWEIBAOTIME"))){
				queryString.append(" and s.WEIBAOTIME <= '"+filterMap.get("ENDWEIBAOTIME")+"'");
				countString.append(" and s.WEIBAOTIME <= '"+filterMap.get("ENDWEIBAOTIME")+"'");
			}
		}
		queryString.append(" order by s.ID desc");
		return searchBySQL(countString.toString(),queryString.toString(),filterMap);
	}

}
